package weatherwidget.isrefluxer.bird.com.birdweatherwidget.until;

import android.content.res.Resources;
import android.text.TextUtils;

import weatherwidget.isrefluxer.bird.com.birdweatherwidget.R;
import weatherwidget.isrefluxer.bird.com.birdweatherwidget.WidgetApplication;

/**
 * Created by Administrator on 2016/11/20 0020.
 */

public class ResourceUtil {
    public static int getResourceByWeather(String weather) {
        if (TextUtils.isEmpty(weather)) {
            return  R.drawable.weather_widget_icon_withoutinfo_s;
        }
        Resources resources = WidgetApplication.getInstance().getResources();
        if (resources.getString(R.string.weather_qing).equals(weather)) {
            return  R.drawable.dualclock_widget_icon_sunny_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_duoyun))) {
            return  R.drawable.dualclock_widget_icon_mostcloudy_night;
        } else if (weather.contains(resources.getString(R.string.weather_yin))) {
            return R.drawable.dualclock_widget_icon_cloud_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_xiaoyu))) {
            return  R.drawable.dualclock_widget_icon_moderate_rain_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_zhongyu))) {
            return  R.drawable.dualclock_widget_icon_moderate_rain_day;
        } else if (weather.contains(resources.getString(R.string.weather_dayu))) {
            return R.drawable.dualclock_widget_icon_moderate_rain_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_zhenyu))) {
            return  R.drawable.dualclock_widget_icon_moderate_rain_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_leizhenyu))) {
            return  R.drawable.dualclock_widget_icon_thunderstorm_day;
        } else if (weather
                .contains(resources.getString(R.string.weather_baoyu))) {
            return  R.drawable.dualclock_widget_icon_moderate_rain_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_dabaoyu))) {
            return  R.drawable.dualclock_widget_icon_moderate_rain_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_tedabaoyu))) {
            return  R.drawable.dualclock_widget_icon_moderate_rain_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_xiaoxue))) {
            return  R.drawable.dualclock_widget_icon_snow_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_zhongxue))) {
            return R.drawable.dualclock_widget_icon_snow_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_zhenxue))) {
            return  R.drawable.dualclock_widget_icon_snow_day;
        } else if (weather
                .contains(resources.getString(R.string.weather_daxue))) {
            return  R.drawable.dualclock_widget_icon_snow_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_yujiaxue))) {
            return  R.drawable.dualclock_widget_icon_snow_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_baoxue))) {
            return  R.drawable.dualclock_widget_icon_snow_day;
        } else if (weather.contains(resources.getString(R.string.weather_yu))) {
            return  R.drawable.dualclock_widget_icon_moderate_rain_day;
        } else if (weather.contains(resources.getString(R.string.weather_xue))) {
            return  R.drawable.dualclock_widget_icon_snow_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_leizhenyubingbao))) {
            return  R.drawable.dualclock_widget_icon_snow_day;
        } else if (weather.contains(resources.getString(R.string.weather_wu))) {
            return  R.drawable.dualclock_widget_icon_haze_day;
        } else if (weather.contains(resources
                .getString(R.string.weather_shachenbao))) {
            return  R.drawable.weather_widget_icon_shachenbao_s;
        } else if (weather.contains(resources
                .getString(R.string.weather_mai))) {
            return  R.drawable.weather_widget_icon_mai_s;
        }
        return R.drawable.weather_widget_icon_withoutinfo_s;
    }
    public static int getResourceByWeather(String weather, boolean isLarge, boolean nightMode)  {
        if (TextUtils.isEmpty(weather)) {
            return isLarge ? R.drawable.weather_widget_icon_withoutinfo_l
                    : R.drawable.weather_widget_icon_withoutinfo_s;
        }
        Resources resources = WidgetApplication.getInstance().getResources();
        if(nightMode && DateUtil.isNight())
        {
            if (resources.getString(R.string.weather_qing).equals(weather)) {
                return R.drawable.dualclock_widget_icon_sunny_night;
            } else if (weather.contains(resources
                    .getString(R.string.weather_duoyun)) ||
                    weather.contains(resources.getString(R.string.weather_yin))) {
                return  R.drawable.dualclock_widget_icon_mostcloudy_night;
            } else {
                return getResourceByWeather(weather);
            }
        }else {
            return getResourceByWeather(weather);
        }

    }
}
